package com.spagettikod.t437.component.domain;

import java.awt.Component;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import com.spagettikod.t437.action.CreateDomainAction;
import com.spagettikod.t437.action.DeleteDomainAction;
import com.spagettikod.t437.action.ExportDomainAction;

public class DomainJListJPopupMenu extends JPopupMenu {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6316259531762309711L;

	private CreateDomainAction createDomainAction;

	private DeleteDomainAction deleteDomainAction;

	private ExportDomainAction exportDomainAction;

	public DomainJListJPopupMenu(DomainJList domainJList) {
		createDomainAction = new CreateDomainAction(domainJList);
		add(new JMenuItem(createDomainAction));
		deleteDomainAction = new DeleteDomainAction(domainJList);
		add(new JMenuItem(deleteDomainAction));
		addSeparator();
		exportDomainAction = new ExportDomainAction(domainJList);
		add(new JMenuItem(exportDomainAction));
	}

	protected void enableExportMenuItem(boolean enable) {
		exportDomainAction.setEnabled(enable);
	}

	protected void enableDeleteMenuItem(boolean enable) {
		deleteDomainAction.setEnabled(enable);
	}

	protected void enableNewMenuItem(boolean enable) {
		createDomainAction.setEnabled(enable);
	}

	protected void showPopupMenu(Component component, int x, int y) {
		show(component, x, y);
	}
}
